<?php

/**
 * Gallery Installer
 * 
 * @package Bd Gallery
 * @author Bebliuc George Cristian
 * @author Gianfranco Liporace
 * @copyright 2008-2010
 * @version 1.3
 * @access public
 * @permisions Modify, Redistribute but leave the credits alive :P
 * @use Noncommercial, for commercial use, please contact me at bebliuc.george@gmail.com, it's for free, but I need to know
 * 
 */

if (Plugin::getSetting('id', 'gallery') === false) {
    // Store settings new style
    $settings = array('id' => 1,
                      'images_folder' => 'images/gallery/',
                      'gallery_page' => '/gallery',
                      'delete_file' => 0,
                      'script' => 'shadowbox',
                      'framework' => 1,
                      'thumbs_per_row' => 3,
                      'thumbnail_height' => 100,
                      'thumbnail_width' => 100,
                      'ratio' => 1,
                      'quality' => 1
                      );

     Plugin::setAllSettings($settings, 'gallery');
}

$PDO = Record::getConnection();
$driver = strtolower($PDO->getAttribute(Record::ATTR_DRIVER_NAME));


//Create Tables

if ($driver == 'mysql')
{
	
$PDO->exec("CREATE TABLE `".TABLE_PREFIX."category` (
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `category_name` varchar(50) NOT NULL default '0',
  `category_description` varchar(300) NOT NULL,
  PRIMARY KEY  (`id`),
  KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;");

$PDO->exec("CREATE TABLE `".TABLE_PREFIX."photos` (
  `photo_title` varchar(100) NOT NULL,
  `id` bigint(20) unsigned NOT NULL auto_increment,
  `photo_filename` varchar(25) default NULL,
  `photo_caption` text,
  `photo_category` bigint(20) unsigned NOT NULL default '0',
  PRIMARY KEY  (`id`),
  KEY `id` (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 ;");

}
else if ($driver == 'sqlite')
{
    $PDO->exec("CREATE TABLE category (
	    id INTEGER NOT NULL PRIMARY KEY,
	    category_name int(11) NOT NULL default '0',
	    category_description text
	)");
		
	$PDO->exec("CREATE TABLE photos (
	    id INTEGER NOT NULL PRIMARY KEY,
	    photo_title int(11) NOT NULL default '0',
	    photo_filename text,
	    photo_caption text,
	    photo_category text
	)");	
}
